# -*- coding:utf-8 -*- 
import xmlrpclib
import os
import urllib2,base64
base_path=os.path.dirname(__file__)
def up():
    s=xmlrpclib.Server('http://s-album.appspot.com/rpc')
    a=s.testapi()
    if a:
        #ph=os.path([base_path,''])
        pass
    else:
        pass
    
        
        
def upfromurl(url,**args):
    '''[name , title , summary , tag ,catalog]'''
    s=xmlrpclib.Server('http://s-album.appspot.com/rpc')
    blob=base64.b64encode(urllib2.urlopen(url).read())
    name=args.get('name') or u'unnamed'
    title = args.get('title') or u'no title'
    summary=args.get('summary') or u'没有相关描述'
    tag=args.get('tag') or u'其他'
    catalog=args.get('catalog') or u'未分类'
    name=base64.b64encode(name)
    title=base64.b64encode(title)
    summary=base64.b64encode(summary)
    img_url=s.saveimg(name,blob,summary,title,tag,catalog)
    print img_url
    
